/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef LIB2D_OBJECTS_ANIMATION_H
#define LIB2D_OBJECTS_ANIMATION_H

#include "Sequence.h"
#include <list>
#include <lib2d/Rect.h>

namespace liba
{
namespace lib2d
{
namespace objects
{

class AnimationRep : public xml::ObjectANSI
{
	std::list< Sequence > sequences;
public:
	explicit AnimationRep( const filesystem::String & name );
	virtual bool on_node( xml::Provider * prov, const std::string & name );
	Sequence * find_sequence( const Atom & name );
};

class Animation :
	public xml::ObjectANSI,
	private Shared<filesystem::String, AnimationRep>
{
	Sequence * sequence;
	int frame;
	float time;
	int loop_direction;	//+1 or -1
	bool finished;

	int alpha;
public:
	Animation( const filesystem::String & name );

	bool start( const Atom & name );
	void life_cycle( float delta_time );
	bool is_finished()const
	{
		return finished;
	}
	void set_transparency( int alpha )
	{
		this->alpha = alpha;
	}
/*	int get_width()const
	{
		if( !sequence )
			return 0;

		return sequence->get_width();
	}
	int get_height()const
	{
		if( !sequence )
			return 0;

		return sequence->get_height();
	}
*/	void render( hard::Renderer * rend );
};

} //namespace objects
} //namespace lib2d
} //namespace liba

using namespace liba;

#endif //LIB2D_OBJECTS_ANIMATION_H